package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.Permission_managementDao;
import com.itheima.domain.Menu_management;
import com.itheima.domain.PageResult;
import com.itheima.domain.Permission_management;
import com.itheima.service.Permission_managementService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@Service
public class Permission_managementImpl implements Permission_managementService {
    @Autowired
    private Permission_managementDao permissionDao;
    @Override
    public List<Permission_management> findAll() {
        return permissionDao.findAll();
    }

    @Override
    public Permission_management findById(Integer userId) {
        return permissionDao.findById(userId);
    }

    @Override
    public void updatePermission(Permission_management permission) {
        permissionDao.updatePermission(permission);
    }

    @Override
    public void save(Permission_management permission_management) {
        permissionDao.save(permission_management);
    }

    @Override
    //删除

    public void delete(Integer id) throws RuntimeException{
        //查询当前检查项是否和检查组关联

        permissionDao.deleteById(id);
    }

    @Override
    public void edit(Permission_management permission_management) {
        permissionDao.edit(permission_management);
    }

    public PageResult pageQuery(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage,pageSize);
        Page<Permission_management> page = permissionDao.selectByCondition(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public List<Permission_management> EstimateFindAll() {
        return permissionDao.EstimateFindAll();
    }

}
